{include file="public/layout" /}
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body web-system" pad15>
                    <div class="layui-form" wid100 lay-filter="">
                        <div class="layui-form-item">
                            <label class="layui-form-label"><b>*</b>级别名称</label>
                            <div class="layui-input-inline">
                                <input type="text" id="level_name" name="level_name" value="" lay-verify="required"  class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><b>*</b>每天免费发布</label>
                            <div class="layui-input-inline">
                                <input type="text" id="free_day_send" name="free_day_send" value="0" lay-verify="number" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                设置为0表示不做限制
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><b>*</b>共免费发布</label>
                            <div class="layui-input-inline">
                                <input type="text" id="free_all_send" name="free_all_send" value="0" lay-verify="number" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                设置为0表示不做限制
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><b>*</b>每天免费置顶</label>
                            <div class="layui-input-inline">
                                <input type="text" id="fee_day_top" name="fee_day_top" value="0" lay-verify="number" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                设置为0表示不做限制
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label"><b>*</b>共免费置顶</label>
                            <div class="layui-input-inline">
                                <input type="text" id="fee_all_top" name="fee_all_top" value="0" lay-verify="number" class="layui-input">
                            </div>
                            <div class="layui-input-inline">
                                设置为0表示不做限制
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">二手房审核</label>
                            <div class="layui-input-inline w70">
                                <input type="checkbox" lay-filter="check_ershou" lay-skin="switch" lay-text="是|否" checked>
                                <input type="hidden" name="check_ershou" value="1" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">出租房审核</label>
                            <div class="layui-input-inline w70">
                                <input type="checkbox" lay-filter="check_zufang" lay-skin="switch" lay-text="是|否" checked>
                                <input type="hidden" name="check_zufang" value="1" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商铺出售审核</label>
                            <div class="layui-input-inline w70">
                                <input type="checkbox" lay-filter="check_shopcs" lay-skin="switch" lay-text="是|否" checked>
                                <input type="hidden" name="check_shopcs" value="1" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">商铺出租审核</label>
                            <div class="layui-input-inline w70">
                                <input type="checkbox" lay-filter="check_shopcz" lay-skin="switch" lay-text="是|否" checked>
                                <input type="hidden" name="check_shopcz" value="1" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">写字楼出售审核</label>
                            <div class="layui-input-inline w70">
                                <input type="checkbox" lay-filter="check_officecs" lay-skin="switch" lay-text="是|否" checked>
                                <input type="hidden" name="check_officecs" value="1" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">写字楼出租审核</label>
                            <div class="layui-input-inline w70">
                                <input type="checkbox" lay-filter="check_officecz" lay-skin="switch" lay-text="是|否" checked>
                                <input type="hidden" name="check_officecz" value="1" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="formSubmit">确认提交</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script>

        $(document).ready(function(){
            // 鼠标事件，加载查看大图和删除图片
            $(".upload-img").live('mouseover', function(){
                $(this).find('div.icaction').show();
                $(this).find('div.cover-bg').show();
            }).live('mouseout', function(){
                $(this).find('div.icaction').hide();
                $(this).find('div.cover-bg').hide();
            });
        });

        layui.config({
            base: '__SKIN__/' //静态资源所在路径
            ,version: '{$version}'
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'set'], function(){
            var $ = layui.$
                ,layer = layui.layer
                ,form = layui.form;

            form.verify({
                check_logo: function(value, item){ //value：表单的值、item：表单的DOM对象
                    if ($('input[name=typeid]:checked').val() == 2) {
                        if(value == ''){
                            return '请上传Logo图片！';
                        }
                    }
                }
            });

            // 监听开关
            form.on('switch', function(data){
                var elemId = data.elem.attributes['lay-filter']['nodeValue'];
                if (data.elem.checked) {
                    this.value = 1;
                } else {
                    this.value = 0;
                }
                $("input[name='"+elemId+"']").val(this.value);
            });

            // 监听单选项
            form.on('radio(typeid)', function(data){
                if (data.value == 2) {
                    $('.typeid2').show();
                } else {
                    $('.typeid2').hide();
                }
            });

            //监听提交
            form.on('submit(formSubmit)', function(data){
                var load = layer_loading();
                data.field._ajax = 1;
                $.ajax({
                    type : 'post',
                    url : "{:url('UsersLevel/add')}",
                    data : data.field,
                    dataType : 'json',
                    success : function(res){
                        layer.close(load); //关闭loading
                        if(res.code == 1){
                            layer.msg(res.msg, {icon: 1, time: 1000}, function(){
                                parent.gourl(res.url);
                            });
                        }else{
                            showErrorMsg(res.msg);
                        }
                    },
                    error: function(e){
                        layer.close(load); //关闭loading
                        showErrorAlert();
                    }
                });
                return false;
            });

        });

    </script>
    {include file="public/footer" /}